import json
import unittest
import requests
from api.login_api import LoginApi
from parameterized.parameterized import parameterized
import app


class TestLogin(unittest.TestCase):
    def setUp(self):
        self.login_api = LoginApi()

    def test01_login(self):
        response = self.login_api.test01_login({"mobile": "13800000002",
                                                "password": "123456"})
        print(response.json())
        self.assertEqual(200, response.status_code)
        self.assertEqual(True, response.json().get('success'))
        self.assertEqual(10000, response.json().get('code'))
        self.assertIn('成功', response.json().get('message'))

        app.TOKEN = 'Bearer ' + response.json().get('data')
        app.headers["Authorization"] = app.TOKEN
